{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-14T08:47:00.200596Z",
     "start_time": "2025-11-14T08:47:00.160787Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "from tomlkit import datetime\n",
    "\n",
    "date_index= pd.to_datetime(['20230110','20230115','20230118'])\n",
    "date_ser= pd.Series([11,22,33],index=date_index)\n",
    "date_ser\n"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2023-01-10    11\n",
       "2023-01-15    22\n",
       "2023-01-18    33\n",
       "dtype: int64"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-14T09:11:46.465093Z",
     "start_time": "2025-11-14T09:11:46.409419Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from datetime import datetime\n",
    "data_demo =[[11,22,33], [44, 55,66],\n",
    "[77,88, 99], [12,23, 34]]\n",
    "date_list =[datetime(2023,1,23),datetime(2023,2,15),\n",
    "            datetime(2023,5,22),datetime(2023,3,30)]\n",
    "time_df= pd.DataFrame(data_demo, index=date_list)\n",
    "time_df\n"
   ],
   "id": "fb697e501639f36f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "             0   1   2\n",
       "2023-01-23  11  22  33\n",
       "2023-02-15  44  55  66\n",
       "2023-05-22  77  88  99\n",
       "2023-03-30  12  23  34"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2023-01-23</th>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-15</th>\n",
       "      <td>44</td>\n",
       "      <td>55</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-22</th>\n",
       "      <td>77</td>\n",
       "      <td>88</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-30</th>\n",
       "      <td>12</td>\n",
       "      <td>23</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-14T09:22:12.083645Z",
     "start_time": "2025-11-14T09:22:12.066942Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "date_list =['2020/05/30','2022/02/01','2020/6/1',\n",
    "'2021/4/1','2022/6/1','2023/1/23']\n",
    "# 根据日期字符串生成DatetimeIndex类的对象\n",
    "date_index= pd.to_datetime(date_list)\n",
    "# 创建Series类的对象，并指定索引是DatetimeIndex\n",
    "date_ser = pd.Series(np.arange(6),index=date_index)\n",
    "date_ser\n"
   ],
   "id": "3902b632f5ea7f75",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020-05-30    0\n",
       "2022-02-01    1\n",
       "2020-06-01    2\n",
       "2021-04-01    3\n",
       "2022-06-01    4\n",
       "2023-01-23    5\n",
       "dtype: int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 10
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
